package com.ts.common.pojo.resp;

import org.apache.http.HttpStatus;

public class TResponse<T> {

    /**
     * 系统自定义错误.
     */
    public static int STATUS_SYSTEM = 10100;
    private static String message;
    private T resultObject;

    private int status;

    private String code;

    private String msg;

    private T data;

    public static TResponse success(String message) {
        TResponse tResponse = new TResponse();
        tResponse.setStatus(200);
        tResponse.setMsg(message);

        return tResponse;
    }

    public static TResponse success(String message, Object resultObject) {
        TResponse tResponse = new TResponse();
        tResponse.setStatus(200);
        tResponse.setMsg(message);
        tResponse.setData(resultObject);

        return tResponse;
    }

    public TResponse success0(String message, T resultObject) {
        TResponse<T> tResponse = new TResponse<T>();
        tResponse.setStatus(200);
        tResponse.setMsg(message);
        tResponse.setData(resultObject);

        return tResponse;
    }

    public static TResponse error(String message) {
        TResponse tResponse = new TResponse();
        tResponse.setStatus(500);
        tResponse.setMsg(message);

        return tResponse;
    }

    public static TResponse error(String code, String message) {
        TResponse tResponse = new TResponse();
        tResponse.setStatus(HttpStatus.SC_BAD_REQUEST);
        tResponse.setCode(code);
        tResponse.setMsg(message);

        return tResponse;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
